Skip to content

Conversation

@pranavkp71
Copy link

This PR adds missing documentation for the Expression class used by pd.col().
The page includes:

  • A short description of the class
  • Example usage inside DataFrame.assign
  • A list of supported operations (arithmetic, comparison, ufuncs, accessors, and Series methods)

Also linked this page in the API reference index so it appears in the built documentation.

@pranavkp71 pranavkp71 force-pushed the doc/add-expression-reference branch from d99d850 to 235e127 Compare November 13, 2025 10:43
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! We generally do not have documentation pages for classes that users are not supposed to instantiate directly (e.g. DataFrameGroupBy). I think this would need some discussion if we are going to add such pages.

@@ -0,0 +1,33 @@
pandas.API.typing.expression
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API documentation is generated from docstrings, not added as files here directly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean I should move this documentation into the Expression class docstring and remove the separate .rst page, index entry, correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd also need to add the Expression class to one of the API doc pages, yes. But as indicated in #63084 (comment), this might be opposed by others on the core team. I think we should ensure the core team is aligned here before moving forward.


**Description**

An ``Expression`` represents a symbolic reference to a DataFrame column.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is false, pd.col("a") + 5 is not a reference to a column, but it is an expression.

Comment on lines +29 to +33
- Arithmetic: ``+``, ``-``, ``*``, ``/``
- Comparison: ``<``, ``>``, ``==``, ``!=``
- Universal functions (ufuncs): can be applied directly
- Series accessors: ``.dt``, ``.str``, ``.cat``
- Series methods: ``.sum()``, ``.mean()``, ``.astype()``, etc.
Copy link
Member

@rhshadrach rhshadrach Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should generate the methods that an expression supports when building the API docs, not hardcode them.

@@ -0,0 +1,33 @@
pandas.API.typing.expression
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd also need to add the Expression class to one of the API doc pages, yes. But as indicated in #63084 (comment), this might be opposed by others on the core team. I think we should ensure the core team is aligned here before moving forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOC: missing docs for pd.col Expression objects

2 participants